Load Libraries

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.0     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.1     ✔ tibble    3.1.8
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ✔ purrr     1.0.1     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the ]8;;http://conflicted.r-lib.org/conflicted package]8;; to force all conflicts to become errors
library(here)
## here() starts at C:/Users/mhein/OneDrive/Desktop/Computer Modeling R Programs/Hein
library(maps)
## 
## Attaching package: 'maps'
## 
## The following object is masked from 'package:purrr':
## 
##     map
library(mapdata)
library(mapproj)
library(ggmap)
## ℹ Google's Terms of Service: <]8;;https://mapsplatform.google.comhttps://mapsplatform.google.com]8;;>
## ℹ Please cite ggmap if you use it! Use `citation("ggmap")` for details.
library(ggsn)
## Loading required package: grid
library(emojifont)

Load Data

ChemData<-read_csv(here("Week_07","data","chemicaldata_maunalua.csv"))
## Rows: 23 Columns: 15
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (4): Zone, Site, Season, Tide_time
## dbl (11): Waypoint, Lat, Long, Temp_in, Salinity, Phosphate, Silicate, NN, p...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
glimpse(ChemData)
## Rows: 23
## Columns: 15
## $ Waypoint    <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,…
## $ Zone        <chr> "Transition", "Transition", "Transition", "Transition", "D…
## $ Lat         <dbl> 21.27531, 21.27523, 21.27504, 21.27449, 21.27503, 21.27485…
## $ Long        <dbl> -157.7618, -157.7627, -157.7633, -157.7640, -157.7617, -15…
## $ Site        <chr> "W", "W", "W", "W", "W", "W", "W", "W", "W", "W", "W", "W"…
## $ Season      <chr> "SPRING", "SPRING", "SPRING", "SPRING", "SPRING", "SPRING"…
## $ Tide_time   <chr> "Low_Day", "Low_Day", "Low_Day", "Low_Day", "Low_Day", "Lo…
## $ Temp_in     <dbl> 23.75506, 23.53256, 22.63450, 24.01982, 23.26102, 24.00517…
## $ Salinity    <dbl> 27.74029, 30.61192, 28.37008, 32.82124, 29.12293, 34.02018…
## $ Phosphate   <dbl> 0.54, 0.36, 0.50, 0.25, 0.50, 0.13, 0.28, 0.15, 0.23, 0.11…
## $ Silicate    <dbl> 157.93, 92.59, 143.60, 42.32, 126.47, 15.04, 56.31, 23.10,…
## $ NN          <dbl> 7.92, 3.37, 7.29, 0.79, 7.45, 0.46, 1.59, 0.34, 1.91, 0.25…
## $ pH          <dbl> 7.909, 7.965, 8.023, 7.995, 8.005, 8.019, 8.003, 7.978, 7.…
## $ TA          <dbl> 2161.482, 2145.828, 2272.391, 2219.583, 2151.826, 2216.758…
## $ percent_sgd <dbl> 20.4043928, 11.9625323, 18.5529716, 5.4677003, 16.3397933,…

Data Analysis

Oahu<-get_map("Oahu")
## ℹ <]8;;https://maps.googleapis.com/maps/api/staticmap?center=Oahu&zoom=10&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxxhttps://maps.googleapis.com/maps/api/staticmap?center=Oahu&zoom=10&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx]8;;>
## ℹ <]8;;https://maps.googleapis.com/maps/api/geocode/json?address=Oahu&key=xxxhttps://maps.googleapis.com/maps/api/geocode/json?address=Oahu&key=xxx]8;;>
ggmap(Oahu)

#Make a data frame of lon and lat coordinates
WP<-data.frame(lon = -157.7621, lat = 21.27427) # coordinates for Wailupe
# Get base layer
Map1<-get_map(WP)
## ℹ <]8;;https://maps.googleapis.com/maps/api/staticmap?center=21.27427,-157.7621&zoom=10&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxxhttps://maps.googleapis.com/maps/api/staticmap?center=21.27427,-157.7621&zoom=10&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx]8;;>
# plot it
ggmap(Map1)

Map1<-get_map(WP,zoom = 17)
## ℹ <]8;;https://maps.googleapis.com/maps/api/staticmap?center=21.27427,-157.7621&zoom=17&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxxhttps://maps.googleapis.com/maps/api/staticmap?center=21.27427,-157.7621&zoom=17&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx]8;;>
ggmap(Map1)

Map1<-get_map(WP,zoom = 17, maptype = "satellite")
## ℹ <]8;;https://maps.googleapis.com/maps/api/staticmap?center=21.27427,-157.7621&zoom=17&size=640x640&scale=2&maptype=satellite&language=en-EN&key=xxxhttps://maps.googleapis.com/maps/api/staticmap?center=21.27427,-157.7621&zoom=17&size=640x640&scale=2&maptype=satellite&language=en-EN&key=xxx]8;;>
ggmap(Map1)

Map1<-get_map(WP,zoom = 17, maptype = "watercolor")
## ! `maptype = "watercolor"` is only available with `source = "stamen"`; resetting source.
## ℹ <]8;;https://maps.googleapis.com/maps/api/staticmap?center=21.27427,-157.7621&zoom=17&size=640x640&scale=2&maptype=terrain&key=xxxhttps://maps.googleapis.com/maps/api/staticmap?center=21.27427,-157.7621&zoom=17&size=640x640&scale=2&maptype=terrain&key=xxx]8;;>
## ℹ Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under CC BY SA.
ggmap(Map1)

Map1<-get_map(WP,zoom = 17, maptype = "satellite") 
## ℹ <]8;;https://maps.googleapis.com/maps/api/staticmap?center=21.27427,-157.7621&zoom=17&size=640x640&scale=2&maptype=satellite&language=en-EN&key=xxxhttps://maps.googleapis.com/maps/api/staticmap?center=21.27427,-157.7621&zoom=17&size=640x640&scale=2&maptype=satellite&language=en-EN&key=xxx]8;;>
ggmap(Map1)+
  geom_point(data = ChemData,
             aes(x = Long, y = Lat, color = Salinity),
             size = 4) +
  scale_color_viridis_c()
## Warning: Removed 2 rows containing missing values (`geom_point()`).

ggmap(Map1)+
  geom_point(data = ChemData, 
             aes(x = Long, y = Lat, color = Salinity), 
             size = 4) + 
  scale_color_viridis_c()+
  scalebar( x.min = -157.766, x.max = -157.758,
           y.min = 21.2715, y.max = 21.2785,
            dist = 250, dist_unit = "m", model = "WGS84", 
            transform = TRUE, st.color = "white",
            box.fill = c("yellow", "white"))
## Warning: Removed 2 rows containing missing values (`geom_point()`).
## Warning: Removed 1 rows containing missing values (`geom_text()`).

geocode("the white house")
## ℹ <]8;;https://maps.googleapis.com/maps/api/geocode/json?address=the+white+house&key=xxxhttps://maps.googleapis.com/maps/api/geocode/json?address=the+white+house&key=xxx]8;;>
## # A tibble: 1 × 2
##     lon   lat
##   <dbl> <dbl>
## 1 -77.0  38.9
geocode("California State University, Northridge")
## ℹ <]8;;https://maps.googleapis.com/maps/api/geocode/json?address=California+State+University,+Northridge&key=xxxhttps://maps.googleapis.com/maps/api/geocode/json?address=California+State+University,+Northridge&key=xxx]8;;>
## # A tibble: 1 × 2
##     lon   lat
##   <dbl> <dbl>
## 1 -119.  34.2
search_emoji('smile')
## [1] "smiley"      "smile"       "sweat_smile" "smiley_cat"  "smile_cat"
ggplot() + 
  geom_emoji('smile_cat', 
             x=1:5, y=1:5, 
             size=10)